﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FATCATool
{
    public partial class MessageSpecControl : UserControl
    {
        MessageSpec_Type _messageSpec;

        public MessageSpecControl()
        {
            InitializeComponent();
        }

        public void Intitalize(MessageSpec_Type messageSpec)
        {
            _messageSpec = messageSpec;
            DataBind();
        }

        private void DataBind()
        {
            txtContact.DataBindings.Clear();
            txtContact.DataBindings.Add("Text", _messageSpec, "Contact");

            txtCorrMessageRefId.DataBindings.Clear();
            txtCorrMessageRefId.DataBindings.Add("Text", _messageSpec, "CorrMessageRefId");

            txtMessageRefId.DataBindings.Clear();
            txtMessageRefId.DataBindings.Add("Text", _messageSpec, "MessageRefId");

            txtSendingCompanyIN.DataBindings.Clear();
            txtSendingCompanyIN.DataBindings.Add("Text", _messageSpec, "SendingCompanyIN");

            txtWarning.DataBindings.Clear();
            txtWarning.DataBindings.Add("Text", _messageSpec, "Warning");

            txtTimeStamp.DataBindings.Clear();
            txtTimeStamp.DataBindings.Add("Text", _messageSpec, "Timestamp");

            cmbMessageType.DataBindings.Clear();
            cmbMessageType.DataSource = Enum.GetValues(typeof(MessageType_EnumType));
            cmbMessageType.DataBindings.Add("SelectedItem", _messageSpec, "MessageType");

            cmbTransmittingCountry.DataBindings.Clear();
            cmbTransmittingCountry.DataSource = Enum.GetValues(typeof(CountryCode_Type));
            cmbTransmittingCountry.DataBindings.Add("SelectedItem", _messageSpec, "TransmittingCountry");

            cmbRecievingCountry.DataBindings.Clear();
            cmbRecievingCountry.DataSource = Enum.GetValues(typeof(CountryCode_Type));
            cmbRecievingCountry.DataBindings.Add("SelectedItem", _messageSpec, "ReceivingCountry");
        }
    }
}
